//
//  FunnyViewController.swift
//  SwiftDemo
//
//  Created by liguoqing on 2022/6/26.
//  Copyright © 2022 guoqing.li. All rights reserved.
//

import UIKit

private let kTopMargin : CGFloat = 8.0

class FunnyViewController : BaseAnchorViewController {
    
    private lazy var funnyViewModel : FunnyViewModel = FunnyViewModel()
    
    override func viewDidLoad() {
        super.viewDidLoad()
            
        let layout = collectionView.collectionViewLayout as! UICollectionViewFlowLayout
        layout.headerReferenceSize = .zero
        collectionView.contentInset = UIEdgeInsets(top: kTopMargin, left: 0, bottom: 0, right: 0)
    }

}

extension FunnyViewController
{
    override func loadData() {
        super.loadData()
        
        baseVM = funnyViewModel
        
        funnyViewModel.loadFunnyData {
            
            self.collectionView.reloadData()
            
            self.loadDataFinished()
        }
    }
}
